package com.special.ResideMenuDemo;

import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.claude.mainactivity.SubjectSelectActivity;
import com.special.ResideMenu.ResideMenu;

public class HomeFragment extends Fragment {

    private View parentView;
    private ResideMenu resideMenu;
    private ImageView mImageView = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        parentView = inflater.inflate(R.layout.home, container, false);
        setUpViews();
        return parentView;
    }

    private void setUpViews() {
        MenuActivity parentActivity = (MenuActivity) getActivity();
        resideMenu = parentActivity.getResideMenu();
        mImageView = (ImageView) parentView.findViewById(R.id.gif);
        mImageView.setBackgroundResource(R.anim.git);
        final AnimationDrawable animationDrawable = (AnimationDrawable)mImageView.getBackground();
        mImageView.post(new Runnable() {
            @Override
                public void run()  {
                    animationDrawable.start();
                }
        });
        parentView.findViewById(R.id.btn_open_menu).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            	gotoSelectClass();
            }
        });

        // add gesture operation's ignored views
        //FrameLayout ignored_view = (FrameLayout) parentView.findViewById(R.id.ignored_view);
        //resideMenu.addIgnoredView(ignored_view);
    }
    
    private void gotoSelectClass() {
		Intent intent = new Intent();
		intent.setClass(getActivity(), SubjectSelectActivity.class);
		getActivity().startActivity(intent);		
	}
    
}
